import React, { useEffect, useState } from 'react'
/* 

*/
export default function App() {

  let [opacity, setopacity] = useState(1)

  // console.log(opacity);
  // console.log(setopacity);

  useEffect(() => {

    let id = setInterval(() => {

      opacity -= 0.1
      if (opacity < 0) {
        opacity = 1
      }
      setopacity(opacity)
    }, 100)
    return () => {
      clearInterval(id)
    }
  }, [])


  return (
    <div>
      <hr />
      <p style={{ opacity }}>我是渐变文字</p>
      <hr />

    </div>
  )
}
